package com.xy.p2p.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.p2p.dao.TroleDao;
import com.xy.p2p.model.Trole;
import com.xy.p2p.service.TroleService;

@Service
@Transactional
public class TroleServiceImpl extends BaseServiceImpl<Trole> implements
		TroleService {
	private TroleDao troleDao;

	public TroleServiceImpl(TroleDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.troleDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return troleDao.checkExist("Trole", paraName, paraValue);
	}

	@Override
	public List<Trole> getTrole(Map<String, Object> map) {
		return troleDao.getTrole(map);
	}
	@Override
	public Pagination getTroleByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return troleDao.getTroleByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Trole save(Trole trole) {
//		trole.setModtime(new Date());
		if(trole.getRoleid()==null){
			//新增
			if(null==trole.getIsSuper())
				trole.setIsSuper("0");
        	return super.save(trole);
		}else{
			//更新
			Trole trole1=troleDao.get(trole.getRoleid());
			try {
				BeanUtil.copyNotNullProperties(trole1, trole);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(trole1);
		}
	}
}